%% load tof data
fileNr = 4;
load(['gestureData\data',num2str(fileNr),'.mat']);

%% get annotated coordinates
inputNum = 3;
i = 962; % start frame number

% check if ANNO has been initialized
try
    load(['Annotation',num2str(fileNr),'.mat'])
catch exception
    ANNO = sparse(size(D,1),inputNum*2);
end

% loop for annotation, save annotated image and coordinates
while i <= size(D,1)
    try
        disp(['frame ',num2str(i)]);
        
        % intensity image
        figure(2);
        imshow(reshape(A(i,:),144,176),[],'Border','tight', 'InitialMagnification', 250);
        colormap('jet')
        set(gcf,'Name',num2str(i))
        
        % depth image
        img = reshape(D(i,:),144,176);
        figure(1);
        imshow(img,[],'Border','tight', 'InitialMagnification', 250);
        colormap('jet')
        set(gcf,'Name',num2str(i))
        
        [x,y,key] = ginput(inputNum);
        % skip data when no body parts is occured
        x(key~=1) = 0;
        y(key~=1) = 0;
        [x,y]
        ANNO(i,:) = reshape([x,y],1,[]);
        save(['Annotation',num2str(fileNr),'.mat'],'ANNO')
        
        i = i + 2;
        
    catch exception
        if strcmp(exception.identifier,'MATLAB:subsassigndimmismatch')
            continue
        else
            disp(exception.stack.line);
            disp(exception.message);
            break
        end
    end
end